package com.itheima.web.request;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * 资源转发
 */
@WebServlet("/demo5")
public class RequestDemo3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("demo5...");
        //模拟请求转发:一种在服务器内部的资源跳转方式
        //请求转发的特点:
        // 浏览器地址栏路径不发生变化
        //只能转发到当前服务器的内部资源
        //一次请求，可以在转发的资源间使用request共享数据
        request.getRequestDispatcher("/demo4").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
